using System;
using System.Collections.Generic;
using System.Text;
using TextEditor.TextDocument.Control;

namespace TextEditor
{
    public class A_VisibleTableBorder : A_Action
    {
        public override string ActionName()
        {
            return "visibledelete";
        }
        public override bool Execute()
        {
            //base.myOwnerDocument._DeleteTable();
            return true;
        }

        public override int CheckState()
        {
            ZYTextTableCell cell = base.myOwnerDocument.GetInTableCell(base.myOwnerDocument.Content.CurrentElement);
            if (cell != null)
            {
                return cell.border ? 1 : 0;
            }
            return base.CheckState();
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.GetInTable(base.myOwnerDocument.Content.CurrentElement) == null ? false : true;
        }

        public override bool UIExecute()
        {
            using (frmTableBorderAndBcolor fbab = new frmTableBorderAndBcolor())
            {
                ZYTextTableCell cell = base.myOwnerDocument.GetInTableCell(base.myOwnerDocument.Content.CurrentElement);
                fbab.SetStyle(cell.Style);
                if (fbab.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (fbab.SelectedIndex == 0)
                        cell.Style = fbab.Style;
                    else
                    {
                        ZYTextTable table = cell.OwnerTable;
                        foreach (ZYTextTableRow row in table.Rows)
                        {
                            foreach (ZYTextTableCell cell1 in row.Cells)
                            {
                                cell1.Style = fbab.Style;
                            }
                        }
                    }
                }
                base.OwnerDocument.OwnerControl.Refresh();
            }
            //base.myOwnerDocument._VibleTable();
            //using (frmSetPageHead head = new frmSetPageHead(this.OwnerDocument))
            //{
            //    head.ShowDialog();
            //}
            return true;
        }
    }
}

